//
//  HDInsuranceCell.swift
//  HuaDaoPeifu
//
//  Created by Erickson on 16/5/10.
//  Copyright © 2016年 paiyipai. All rights reserved.
//

import UIKit

class HDInsuranceCell: UITableViewCell {
    
    @IBOutlet weak var topLabel: UILabel!
    @IBOutlet weak var middleLabel: UILabel!
    @IBOutlet weak var bottomLabel: UILabel!
    @IBOutlet weak var icon: UIImageView!
    @IBOutlet weak var statusImageView: UIImageView!
    
    @IBOutlet weak var IDLabel: UILabel!
    @IBOutlet weak var badgeView: UIView!
    
    
    let offlineFlogImageView = UIImageView()

    override func awakeFromNib() {
        super.awakeFromNib()
        //106 * 31
        offlineFlogImageView.image = UIImage(named: "tips")
        contentView.addSubview(offlineFlogImageView)
        offlineFlogImageView.snp.makeConstraints { (make) in
            make.width.equalTo(53)
            make.height.equalTo(15)
            make.left.equalTo(icon.snp.left).offset(-3)
            make.top.equalTo(icon.snp.top).offset(3)
        }
        offlineFlogImageView.isHidden = true
    }

    var policyListModel:HDPolicyListModel? {
        didSet {
            
        }
    }
    
    var archive:HDPolicyModel? {
        didSet {
            if let arch = archive {

                topLabel.text = arch.INSURANCE_NAME
                
                middleLabel.text = arch.product_name
                
                bottomLabel.text = "保险期间: "+arch.STARTTIME+" - "+arch.ENDTIME
                
                IDLabel.text = "ID号:" + arch.id
                // 案件状态：  1:初审中  2:初审退回  3&9:预结案  4:已结案 6：审核中 5：待补件  7：关闭案件  16：申诉中 18：放弃案件
                if let imageName = HDPolicyModel.statusImageName(Status: arch.status) {
                    statusImageView.isHidden = false
                    statusImageView.image = UIImage(named: imageName)
                }else{
                    statusImageView.isHidden = true
                }
                
                icon.sd_setImage(with: URL(string: (kBaseApiv2URL+arch.img))!)

            }

        }
    }
}
